layui.use(['form','layer','laydate','table','laytpl'],function(){
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery,
        laydate = layui.laydate,
        laytpl = layui.laytpl,
        table = layui.table;

    //修改密码
    form.on("submit(changePwd)",function(){
        var index = layer.msg('提交中，请稍候',{icon: 16,time:false,shade:0.8});
        if ( $("#oldPwd").val() == $("#newPwd").val() && $("#oldPwd").val() != $("#pwd").val()) {
            $.ajax({
                url : "changePwd",
                type : "post",
                data : {
                    userId : $("#hId").val(),
                    oldPwd : $("#pwd").val(),
                    newPwd : $("#newPwd").val()
                },
                success : function (result) {
                    if (result.code == 100) {
                        setTimeout(function(){
                            layer.close(index);
                            layer.msg("修改成功！");
                        },500);
                    } else {
                        setTimeout(function(){
                            layer.close(index);
                            layer.msg(result.extend.msg);
                        },500);
                    }
                }
            })
        } else {
            layer.msg("俩次输入密码不同");
        }

        return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
    })

})